﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ViCode_LeVi.Controls
{
    /// <summary>
    /// Interaction logic for VMTaskItemGroupSummary.xaml
    /// </summary>
    public partial class VMTaskItemGroupSummary : UserControl
    {
        public VMTaskItemGroupSummary()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(VMTaskItemGroupSummary_Loaded);
            this.SizeChanged += new SizeChangedEventHandler(VMTaskItemGroupSummary_SizeChanged);
        }

        void VMTaskItemGroupSummary_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            Setup_GridViewColumn_Define();
        }

        void VMTaskItemGroupSummary_Loaded(object sender, RoutedEventArgs e)
        {
            Setup_GridViewColumn_Define();
        }
        void Setup_GridViewColumn_Define()
        {
            GridView gv = ListView_Tasks.View as GridView;
            if (gv != null && gv.Columns.Count>0)
            {
                var sumW = gv.Columns.Where(c => c != GridViewColumn_Define).Select(c => c.ActualWidth).Sum();
                var w = ListView_Tasks.ActualWidth - sumW - 20;
                if (w > 0)
                    GridViewColumn_Define.Width = w;
            }
        }
    }
}
